<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
       <script src="__PUBLIC__/plugins/layer/layer.min.js"></script>
      <style type="text/css">
		#preview{border:1px solid #cccccc; background:#CCC;color:#fff; padding:5px; display:none; position:absolute;}
	  </style>
   </head>
   <script>

       function notPass(auctionId) {
           var w = layer.open({
               type: 1,
               title:"提交原因",
               shade: [0.6, '#000'],
               border: [0],
               content: '<textarea id="rejectionRemarks" rows="8" style="width:96%;margin:2% 2%;" maxLength="100"></textarea>',
               area: ['500px', '250px'],
               btn: ['提交', '关闭窗口'],
               yes: function(index, layero){
                   var rejectionRemarks = $.trim($('#rejectionRemarks').val());
                   if(rejectionRemarks==''){
                       WST.msg('请输入不通过的原因 !', {icon: 5});
                       return;
                   }
                   var ll = layer.load('数据处理中，请稍候...');
                   $.post("{:U('Admin/Auction/auctionNotPass')}",{auctionId:auctionId,rejectionRemarks:rejectionRemarks},function(data){
                       layer.close(w);
                       layer.close(ll);
                       var json = WST.toJson(data);
                       if(json==1){
                           WST.msg('操作成功!', {icon: 5});
                           location.reload();
                       }else{
                           WST.msg('操作失败!', {icon: 5});
                       }
                   });
               }
           });
       }

       function changeStatus(id,v){
           var param={};
           param.id=id;
           param.status=v;
           param.auctionStartTime=$('#auctionStartTime'+id).text();
           param.auctionEndTime=$('#auctionEndTime'+id).text();

           Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
           $.post("{:U('Admin/Auction/changePenddingGoodsStatus')}",param,function(data,textStatus){
               var json = WST.toJson(data);
               if(json.status=='1'){
                   Plugins.setWaitTipsMsg({ content:'操作成功',timeout:1000,callback:function(){
                       location.href="{:U('Admin/Auction/queryPenddingByPage')}";
                   }});
               }else{
                   Plugins.closeWindow();
                   Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});

               }
           });
       }

   $.fn.imagePreview = function(options){
		var defaults = {}; 
		var opts = $.extend(defaults, options);
		var t = this;
		xOffset = 5;
		yOffset = 20;
		if(!$('#preview')[0])$("body").append("<div id='preview'><img width='200' src=''/></div>");
		$(this).hover(function(e){
			   $('#preview img').attr('src',"__ROOT__/"+$(this).attr('img'));      
			   $("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").show();      
		  },
		  function(){
			$("#preview").hide();
		}); 
		$(this).mousemove(function(e){
			   $("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
		});
	}
   function getAreaList(objId,parentId,t,id){
	   var params = {};
	   params.parentId = parentId;
	   $('#'+objId).empty();
	   if(t<1){
		   $('#areaId2').html('<option value="">请选择</option>');
		   if(parentId==0)return;
	   }
	   var html = [];
	   $.post("{:U('Admin/Areas/queryByList')}",params,function(data,textStatus){
		    html.push('<option value="">请选择</option>');
			var json = WST.toJson(data);
			if(json.status=='1' && json.list.length>0){
				var opts = null;
				for(var i=0;i<json.list.length;i++){
					opts = json.list[i];
					html.push('<option value="'+opts.areaId+'" '+((id==opts.areaId)?'selected':'')+'>'+opts.areaName+'</option>');
				}
			}
			$('#'+objId).html(html.join(''));
	   });
   }
   function getCatList(objId,parentId,t,id){
	   var params = {};
	   params.id = parentId;
	   $('#'+objId).empty();
	   if(t<1){
		   $('#goodsCatId3').empty();
		   $('#goodsCatId3').html('<option value="0">请选择</option>');
		   if(parentId==0){
			   $('#goodsCatId2').html('<option value="0">请选择</option>');
			   return;
		   }
	   }
	   var html = [];
	   $.post("{:U('Home/GoodsCats/queryByList')}",params,function(data,textStatus){
		    html.push('<option value="0">请选择</option>');
			var json = WST.toJson(data);
			if(json.status=='1' && json.list){
				var opts = null;
				for(var i=0;i<json.list.length;i++){
					opts = json.list[i];
					html.push('<option value="'+opts.catId+'" '+((id==opts.catId)?'selected':'')+'>'+opts.catName+'</option>');
				}
			}
			$('#'+objId).html(html.join(''));
	   });
  }
  $(document).ready(function(){
	    $('.imgPreview').imagePreview();
	    <notempty name='areaId1'>
		getAreaList("areaId2",'{$areaId1}',0,'{$areaId2}');
		</notempty>
		<if condition="$goodsCatId1  neq 0 ">
		getCatList("goodsCatId2",{$goodsCatId1},0,{$goodsCatId2});
		</if>
		<if condition="$goodsCatId2 neq 0 ">
		getCatList("goodsCatId3",{$goodsCatId2},1,{$goodsCatId3});
		</if>
  });
   </script>
   <body class='wst-page'>
    <form method='post' action='{:U("Admin/auction/queryPenddingByPage")}'>
       <div class='wst-tbar'> 
      地区：<select id='areaId1' name='areaId1' onchange='javascript:getAreaList("areaId2",this.value,0)'>
               <option value=''>请选择</option>
               <volist name="areaList" id="vo">
               <option value='{$vo['areaId']}' <if condition="$areaId1 == $vo['areaId'] ">selected</if>>{$vo['areaName']}</option>
               </volist>
             </select>
             <select id='areaId2' name='areaId2'>
               <option value=''>请选择</option>
             </select>
  商城分类：<select id='goodsCatId1' name='goodsCatId1' onchange='javascript:getCatList("goodsCatId2",this.value,0)'>
	                <option value='0'>请选择</option>
	                <volist name="goodsCatsList" id="vo">
	                <option value='{$vo['catId']}' <if condition="$goodsCatId1 == $vo['catId'] ">selected</if>>{$vo['catName']}</option>
	                </volist>
	             </select>
	             <select id='goodsCatId2' name='goodsCatId2' onchange='javascript:getCatList("goodsCatId3",this.value,1);'>
	                <option value='0'>请选择</option>
	             </select>
	             <select id='goodsCatId3' name='goodsCatId3'>
	                <option value='0'>请选择</option>
	             </select>
   </div>
   <div class='wst-tbar'>             
       所属店铺：<input type='text' id='shopName' name='shopName' value='{$shopName}'/>          
       商品：<input type='text' id='goodsName' name='goodsName' value='{$goodsName}'/> 
  <button type="submit" class="btn btn-primary glyphicon glyphicon-search">查询</button> 
       </div>
       </form>
       <div class='wst-body'>
        <table class="table table-hover table-striped table-bordered wst-list">
           <thead>
             <tr>
               <th width='30'>序号</th>
               <th width='150'>商品名称</th>
               <th width='60'>商品编号</th>
               <th width='40'>店铺</th>
               <th width='30'>起拍价</th>
                 <th width='30'>递增价</th>
                 <th width='30'>一口价</th>
                 <th width='30'>中标数</th>
               <th width='30'>状态</th>
               <th width='70'>开始时间</th>
               <th width='70'>结束时间</th>
               <th width='75'>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="Page['root']" id="vo" key='i'>
             <tr>
               <td><input type='checkbox' class='chk' name='chk_{$vo['goodsId']}' value='{$vo['goodsId']}'/>{$i}</td>
               <td img='{$vo['goodsThums']}' class='imgPreview'>
               <img src='__ROOT__/{$vo['goodsThums']}' width='50'/>
               {$vo['goodsName']}
               </td>
               <td>{$vo['goodsSn']}&nbsp;</td>
               <td><a href="{:U('Admin/Group/queryPenddingByPage',array('shopName'=>$vo['shopName']))}">{$vo['shopName']}</a>&nbsp;</td>
               <td>{$vo['auctionLowPrice']}&nbsp;</td>

               <td>{$vo['auctionAddPrice']}&nbsp;</td>
               <td>{$vo['auctionMinPrice']}</td>
               <td>{$vo['auctionWinNum']}&nbsp;</td>
               <td>
                     <if condition="$vo['goodsAuctionStatus'] eq 0">待审核</if>
                     <if condition="$vo['goodsAuctionStatus'] eq 2">不通过</if>
               </td>
               <td id="auctionStartTime{$vo['id']}">{$vo['auctionStartTime']}</td>
               <td id="auctionEndTime{$vo['id']}">{$vo['auctionEndTime']}</td>
               <td>
               <a class="btn btn-primary glyphicon" href='{:U("Admin/auction/toPenddingView",array("id"=>$vo["goodsId"]))}'>查看</a>
               <php>if(in_array('spsh_04',$WST_STAFF['grant'])){</php>
               <button type="button" class="btn btn-success glyphicon" onclick="javascript:changeStatus({$vo['id']},1)">通过</button>&nbsp;
               <button type="button" class="btn btn-danger glyphicon glyphicon-pencil" onclick="javascript:notPass({$vo['id']})">不通过</button>&nbsp;
               <php>}</php>
               </td>
             </tr>
             </volist>
             <tr>
                <td colspan='12' align='center'>{$Page['pager']}</td>
             </tr>
           </tbody>
        </table>
       </div>
   </body>
</html>